import request from '../../../util/request'
import type { ResponseSkuData } from './type'

enum API {
  // 获取SKU列表数据
  GET_SKULIST_URL = '/admin/product/list',
  // SKU商品上架接口
  ON_SALE_URL = '/admin/product/onSale/',
  // SKU商品下架接口
  CANNEL_SALE_URL = '/admin/product/cancelSale/',
  // 获取SKU信息
  GET_SKU_INFO_URL = '/admin/product/getSkuInfo/',
  // 删除某个SKU信息
  DELETE_SKU_URL = '/admin/product/deleteSku/',
}

export const reqSkuList = (page: number, limit: number) => {
  return request.get<any, ResponseSkuData>(
    API.GET_SKULIST_URL + `/${page}/${limit}`,
  )
}

export const reqOnSale = (skuId: number) => {
  return request.get<any, any>(API.ON_SALE_URL + `${skuId}`)
}

export const reqCannelSale = (skuId: number) => {
  return request.get<any, any>(API.CANNEL_SALE_URL + `${skuId}`)
}

export const reqGetSkuInfo = (skuId: number) => {
  return request.get<any, any>(API.GET_SKU_INFO_URL + `${skuId}`)
}

export const reqDeleteSku = (skuId: number) => {
  return request.delete<any, any>(API.DELETE_SKU_URL + `${skuId}`)
}
